package com.huaxin.device.dto.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import com.huaxin.hxenum.base.BaseCodeEnum;

/**
 * 电压等级枚举
 */
public enum VoltageLevel implements BaseCodeEnum<String> {

    LV_220V("220V", "低压 - 220V"),
    LV_380V("380V", "低压 - 380V"),
    MV_10KV("10KV", "中压 - 10kV"),
    MV_20KV("20KV", "中压 - 20kV"),
    MV_35KV("35KV", "中压 - 35kV"),
    HV_110KV("110KV", "高压 - 110kV"),
    HV_220KV("220KV", "高压 - 220kV");

    @EnumValue
    private final String code;
    private final String displayName;

    VoltageLevel(String code, String displayName) {
        this.code = code;
        this.displayName = displayName;
    }

    @JsonValue
    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getDisplayName() {
        return displayName;
    }

    public static VoltageLevel of(String code) {
        for (VoltageLevel type : values()) {
            if (type.getCode().equalsIgnoreCase(code)) {
                return type;
            }
        }
        return null;
    }

    public static boolean isValid(String code) {
        return of(code) != null;
    }
}